package verificateur;
import math.Fraction;

import java.util.Arrays;
import java.util.HashMap;

import structureDonnee.Inequalite;
import structureDonnee.Invariant;


public class Simplex {
	public  HashMap<Integer, Fraction> c;
	public  Fraction valObj ;
	public  HashMap <Integer, Integer> vrbl; // Mapping of the variable to 0 means the bariable is non-basic
	// Mapping of the variable to 1 means the variable is basic.
	public  HashMap <Integer, HashMap<Integer,Fraction>> coeffmtrx;
	public  HashMap <Integer, Fraction> valVrbl; 
	
	public Simplex (){
		c= new HashMap<Integer, Fraction>();
		valObj= new Fraction(0);
		vrbl = new HashMap <Integer, Integer> (); 
		coeffmtrx=new HashMap <Integer, HashMap <Integer,Fraction> >();
		valVrbl=new HashMap <Integer, Fraction>();
	}

	/* The constraints are of the forme Ax<=b where, b are all non negatives.
		We are solving Maximasation problems
		 We are trying to solve the folowing equation 
		 Z= 3x1 + x2 + 2x3
		 sous 
		 x4= 30- x1- x2- 3x3
		 x5= 24-2x1-2x2- 5x3
		 x6= 36-4x1-x2-2x3
	 */ 

	public static void pivot(Simplex s, int l, int e){
		//System.out.println("Leaving vector is "+l);
		
		
		s.valVrbl.put(e, s.valVrbl.get(l).dividedBy(s.coeffmtrx.get(l).get(e)));
		
		for(int j=1;j<=s.vrbl.size();j++){
			if(s.vrbl.get(j)==0&&j!=e){
				s.coeffmtrx.get(e).put(j,s.coeffmtrx.get(l).get(j).dividedBy(s.coeffmtrx.get(l).get(e)));
			}		
		}
		s.coeffmtrx.get(e).put(l,s.coeffmtrx.get(l).get(e).inverse());

		for (int i=1;i<=s.vrbl.size();i++){
			if(s.vrbl.get(i)==1&&i!=l){
				s.valVrbl.put(i,s.valVrbl.get(i).minus(s.coeffmtrx.get(i).get(e).times(s.valVrbl.get(e))));
				for(int j=1;j<=s.vrbl.size();j++){
					if(s.vrbl.get(j)==0 && j!=e)
						s.coeffmtrx.get(i).put(j,s.coeffmtrx.get(i).get(j).minus(s.coeffmtrx.get(i).get(e).times(s.coeffmtrx.get(e).get(j))));
				}
				s.coeffmtrx.get(i).put(l,s.coeffmtrx.get(i).get(e).times(s.coeffmtrx.get(e).get(l)).negative());  
			}
		}

		s.valVrbl.put(l, new Fraction(0));
		s.valObj=s.valObj.plus(s.c.get(e).times(s.valVrbl.get(e)));

		for(int j=1;j<=s.vrbl.keySet().size();j++){
			if(s.vrbl.get(j)==0 && j!=e){
				s.c.put(j,s.c.get(j).minus(s.c.get(e).times(s.coeffmtrx.get(e).get(j))));
			}
		}

		s.c.put(l,s.c.get(e).times(s.coeffmtrx.get(e).get(l)).negative());
		for (int i=1;i<=s.vrbl.size();i++){
			if(s.vrbl.get(i)==1 && i!=l)
				s.coeffmtrx.get(i).put(e,new Fraction (0));
		}
		for (int i=1;i<=s.vrbl.size();i++){
			s.coeffmtrx.get(l).put(i, new Fraction (0));
		}
		s.c.put(e,new Fraction (0));

		s.vrbl.put(e,1);
		s.vrbl.put(l,0);
   	}
	
	public static double LinearProgramming(Simplex s){
		if(s==null) System.out.println("Simplex is null");
		Fraction []cs = new Fraction[s.c.size()];
		int e,l;
		int B=0;
		int N=0;
		for(int i=1;i<=s.vrbl.size();i++){
			if(s.vrbl.get(i)==1)
				B++;
			else 
				N++;
		}
		Fraction [] delta= new Fraction[s.vrbl.size()];
		for (int i=0;i<cs.length;i++)
			 cs[i]=new Fraction(s.c.get(i+1));
						
		while(Fraction.max(cs).compareTo(0)==1){
		    e = Fraction.indxfirstpostv(cs)+1;
			int i=0;
			for(int j=1;j<=s.vrbl.size();j++){
				if(s.vrbl.get(j)==1){
					if( s.coeffmtrx.get(j).get(e).compareTo(0)==1){
						delta[i]=new Fraction(s.valVrbl.get(j).dividedBy(s.coeffmtrx.get(j).get(e)));
						i++;
					}
					else {
						delta[i]=new Fraction((int)Double.POSITIVE_INFINITY);
					     i++;	
					}
				}
				else{ 
					delta[i]= new Fraction((int)Double.POSITIVE_INFINITY);i++;}
				}
			l = Fraction.indxmin(delta)+1;
			
			if(delta[l-1]==new Fraction((int)Double.MAX_VALUE)) 
				return Double.POSITIVE_INFINITY;
			else pivot(s,l,e);
		//	System.out.println();
		//	System.out.println("AFFICHE LA BASE");
			for (int m=0;m<cs.length;m++)
				 cs[m]=new Fraction(s.c.get(m+1));
		//	for(int f=1;f<=s.vrbl.size();f++)System.out.println(f+ "|"+ s.vrbl.get(f));
			
		//	System.out.println();
		
		
		//	for(int f=1;f<=s.vrbl.size();f++)	System.out.println(f+ "fonction<obj|"+ s.c.get(f));
			
		//	for(int f=1;f<=s.vrbl.size();f++)	System.out.println(f+ "b|"+ s.valVrbl.get(f));

			
		//	for(int p=1;p<=s.vrbl.size();p++){
		//		System.out.println("The value of x"+p+"is "+s.valVrbl.get(p));
		//		System.out.println();
			//}
		}
		return s.valObj.asDouble();	
	}
		                            
	public static Simplex Intialisation_Simplex(int A [][], int []b, int []c){
		Simplex s= new Simplex();
		Simplex snew= new Simplex();
		
		int m=b.length;
		int n=c.length;
	//	System.out.println("debut! n= "+n+" m= "+m);
		int indxb=0;
		int indxc=0;
		int indx=0;
		Fraction []fb= new Fraction [m+n];
		for(int i=1;i<=m+n;i++){
			if(i<=n)
				fb[i-1]= new Fraction(0);
			else{
				fb[i-1]= new Fraction(b[indx]);
				indx++;
			}
		}
		
		//int l= Fraction.indxmin(fb);
		int l = Fraction.indxmin(fb)+1;
		
		if (fb[Fraction.indxmin(fb)].compareTo(0)==1||fb[Fraction.indxmin(fb)].equals(0)){
			//System.out.println("Entered the if part of Initailisation");
			for (int i=1;i<=m+n;i++){
				s.coeffmtrx.put(i,new HashMap<Integer, Fraction>());
				if(i<=n){
					s.valVrbl.put(i,new Fraction(0));
				    s.vrbl.put(i,0);
				    s.c.put(i,new Fraction(c[indxc]));
				    for(int j=1;j<=m+n;j++)
				    	s.coeffmtrx.get(i).put(j,new Fraction(0));
				    indxc++;
				}
				else{
					s.vrbl.put(i,1);
					s.valVrbl.put(i,new Fraction(b[indxb]));
					s.c.put(i,new Fraction(0));
					for(int j=1;j<=m+n;j++){
						if(j<=n)
							s.coeffmtrx.get(i).put(j,new Fraction(A[indxb][j-1]));
						else 
							s.coeffmtrx.get(i).put(j,new Fraction(0));
					}
					indxb++;
				}
			}
			s.valObj=new Fraction (0);
			return s;
		}
		
		
		else {
			//System.out.println("Entered the else part of Initialisation");
			for (int i=1;i<=m+n+1;i++){
				s.coeffmtrx.put(i,new HashMap<Integer, Fraction>());
				
				if(i==m+n+1){                            // Variable auxilaire
					s.vrbl.put(i,0);
					s.valVrbl.put(i,new Fraction (0));
					s.c.put(i,new Fraction (-1));
					for(int j=1;j<=m+n+1;j++)
						s.coeffmtrx.get(i).put(j,new Fraction (0));
				}
				else if(i<=n){
					s.valVrbl.put(i,new Fraction(0));
				    s.vrbl.put(i,0);
				    s.c.put(i,new Fraction(0));
				    for(int j=1;j<=m+n+1;j++)
				    	s.coeffmtrx.get(i).put(j,new Fraction(0));
		    
				}
				else {
			//		System.out.println("! n= "+n+" m= "+m);
					s.vrbl.put(i,1);
					s.valVrbl.put(i,new Fraction(b[indxb]));
					s.c.put(i,new Fraction(0));
					for(int j=1;j<=m+n+1;j++){
						if(j<=n){
//							System.out.println("@@@@@@@@@@@@@@@@@@j="+j+" i= "+i+" indxb= "+indxb);
							s.coeffmtrx.get(i).put(j,new Fraction(A[indxb][j-1]));
						}
						else if(j==m+n+1) 
							///////x0 ajouter
							s.coeffmtrx.get(i).put(j,new Fraction(-1));
						else  
							s.coeffmtrx.get(i).put(j,new Fraction (0));
					}
					indxb++;
			
				}
			}
			s.valObj=new Fraction (0);
			//System.out.println("After initialisation :");
			//System.out.println("The value of l is"+l);
	//		for(int i=1;i<=s.vrbl.size();i++){
	//			for(int j=1;j<=s.vrbl.size();j++){
	//				System.out.print(" "+ s.coeffmtrx.get(i).get(j)+";");
	//			}
	//			System.out.println();
	//		}
	//		for(int f=1;f<=s.vrbl.size();f++)
	//			System.out.println(f+ " avant pivo base ou non base| "+ s.vrbl.get(f));

		//	System.out.println();
			
	//		for(int f=1;f<=s.vrbl.size();f++)
		//		System.out.println(f+ " coefi de fonction obj| "+ s.c.get(f));
			
		//	for(int f=1;f<=s.vrbl.size();f++)
	//			System.out.println(f+ " b| "+ s.valVrbl.get(f));
			
	//		System.out.println();
	//		System.out.println("Starting pivoting of the phase 1");	
			
			pivot(s,l,m+n+1);
			
	//		System.out.println("After pivoting");
			
	//		for(int i=1;i<=s.vrbl.size();i++){
	//			for(int j=1;j<=s.vrbl.size();j++){
	//				System.out.print(" "+ s.coeffmtrx.get(i).get(j)+":");
	//			}
	//			System.out.println();
	//		}
			
	//		for(int f=1;f<=s.vrbl.size();f++)
		//		System.out.println(f+ " apre pivo base| "+ s.vrbl.get(f));
			
	//		System.out.println();
			
	//		for(int f=1;f<=s.vrbl.size();f++)
	//			System.out.println(f+ " apre coffi| "+ s.c.get(f));
			
		//	for(int f=1;f<=s.vrbl.size();f++)
	//			System.out.println(f+ " apre b|"+ s.valVrbl.get(f));
			
	//		System.out.println();
		
		//	System.out.print ("11111 function obj is "+LinearProgramming(s));
			LinearProgramming(s);
			if(!s.valVrbl.get(m+n+1).equals(0)){
				return null;
			}
					
			else{
		//		System.out.print("Now in else's else");
		//		for(int i=1;i<=s.vrbl.size();i++)	System.out.println("phase 2 The value of x "+i+"is"+s.valVrbl.get(i));
		//		System.out.println();
		//		for(int i=1;i<=s.vrbl.size();i++)	System.out.println(" The value of c "+i+" is "+s.c.get(i));
				for (int i=1;i<=m+n;i++)
					snew.coeffmtrx.put(i,new HashMap<Integer, Fraction>());
				for(int i=1;i<=m+n;i++){
					if(s.vrbl.get(i)==0){
						snew.vrbl.put(i,0);
					    snew.valVrbl.put(i,new Fraction(0));	
					    for (int j=1;j<=m+n;j++)
					    	snew.coeffmtrx.get(i).put(j, new Fraction(0));
					}
					else {
						snew.vrbl.put(i,1);
					    snew.valVrbl.put(i,s.valVrbl.get(i));
					    for (int j=1;j<=m+n;j++){
					    	snew.coeffmtrx.get(i).put(j,s.coeffmtrx.get(i).get(j));
					    }
					}
				}
				Fraction tmp= new Fraction(0);
				for (int i=1;i<=n;i++)
					if(s.vrbl.get(i)==1)
						tmp= tmp.plus(s.valVrbl.get(i).times(c[i-1]));
				
				snew.valObj= new Fraction(tmp).plus(s.valObj);
           				
				for (int p=1;p<=m+n;p++){
					int i=1;
           			Fraction tmp2= new Fraction(0);
           			do{
           				if(s.vrbl.get(i)==1)
           					tmp2=tmp2.plus(s.coeffmtrx.get(i).get(p).times(-c[i-1]));
           				i++;
           			}while (i<=n);
           			//System.out.println("the value of tmp2 is"+tmp2);
           			if(p<=n)
           				snew.c.put(p, tmp2.plus(c[p-1]));
           			else 
           				snew.c.put(p,tmp2);
				}	
			}
			for (int i=1;i<=m+n;i++){
				if(s.vrbl.get(i)==1) 
					snew.c.put(i, new Fraction(0));
			}
			
		/*	// System.out.print("the new value ouias s"+snew.valObj);
			System.out.println(" apres tout Calculating the new value of c ");
			for (int i=1;i<=snew.c.size();i++){
				System.out.println(" apre phase fonction obj "+ snew.c.get(i));
            }
            for (int i=1;i<=snew.c.size();i++){
            	System.out.println("apre phase b "+snew.valVrbl.get(i));
            }
            System.out.println("fonction objective de phase "+snew.valObj);
          */  
			return snew;
		}
	}
	
	public static HashMap<Integer, Fraction> solutionOptimale(int A [][], int []b, int []c){
		Simplex snw = Intialisation_Simplex(A,b,c);
		if(snw!=null){
			LinearProgramming(snw);
			HashMap<Integer,Fraction> so = new HashMap<Integer,Fraction>();
			for(int i = 0; i< c.length/2;i++){
				Fraction tmp = new Fraction(snw.valVrbl.get(i+1).minus(snw.valVrbl.get(i+1+c.length/2)));
				so.put(i, tmp);
	//			so.put(i, snw.valVrbl.get(i+1));
			}		
			return so;			
		}
		else{
			return null;
		}

	}

	public boolean verifierImplication(Invariant env, Invariant inv){
		return true;
	}
	
	public static void main(String [] args){
		Simplex s= new Simplex ();
		
	/*	Prob 1:
	 *  s.c.put(1, new Fraction(3));
		s.c.put(2, new Fraction(1));
		s.c.put(3, new Fraction(2));
		s.c.put(4, new Fraction(0));
		s.c.put(5, new Fraction(0));
		s.c.put(6, new Fraction(0));

		s.valObj=new Fraction (0);
		s.vrbl.put(1,0);
		s.vrbl.put(2,0);
		s.vrbl.put(3,0);
		s.vrbl.put(4,1);
		s.vrbl.put(5,1);
		s.vrbl.put(6,1);
		for(int i=1;i<7;i++) {
			s.coeffmtrx.put(i,new HashMap<Integer, Fraction>());
			for(int j=1;j<7;j++){
				if(i<4)
					s.coeffmtrx.get(i).put(j,new Fraction(0));
			}
		}
		s.coeffmtrx.get(4).put(1,new Fraction (1));
		s.coeffmtrx.get(4).put(2,new Fraction (1));
		s.coeffmtrx.get(4).put(3,new Fraction (3));
		s.coeffmtrx.get(4).put(4,new Fraction (0));
		s.coeffmtrx.get(4).put(5,new Fraction (0));
		s.coeffmtrx.get(4).put(6,new Fraction (0));

		s.coeffmtrx.get(5).put(1,new Fraction (2));
		s.coeffmtrx.get(5).put(2,new Fraction (2));
		s.coeffmtrx.get(5).put(3,new Fraction (5));
		s.coeffmtrx.get(5).put(4,new Fraction (0));
		s.coeffmtrx.get(5).put(5,new Fraction (0));
		s.coeffmtrx.get(5).put(6,new Fraction (0));

		s.coeffmtrx.get(6).put(1,new Fraction (4));
		s.coeffmtrx.get(6).put(2,new Fraction (1));
		s.coeffmtrx.get(6).put(3,new Fraction (2));
		s.coeffmtrx.get(6).put(4,new Fraction (0));
		s.coeffmtrx.get(6).put(5,new Fraction (0));
		s.coeffmtrx.get(6).put(6,new Fraction (0));

		s.valVrbl.put(1, new Fraction (0));
		s.valVrbl.put(2, new Fraction (0));
		s.valVrbl.put(3, new Fraction (0));
		s.valVrbl.put(4, new Fraction (30));
		s.valVrbl.put(5, new Fraction (24));
		s.valVrbl.put(6, new Fraction (36));
		*/
		/*
		 * 
		 * Prob 2:
		s.c.put(1, new Fraction(6));
		s.c.put(2, new Fraction(5));
		s.c.put(3, new Fraction(0));
		s.c.put(4, new Fraction(0));
		
		s.valObj=new Fraction (0);
		
		s.vrbl.put(1,0);
		s.vrbl.put(2,0);
		s.vrbl.put(3,1);
		s.vrbl.put(4,1);
		
		for(int i=1;i<5;i++) {
			s.coeffmtrx.put(i,new HashMap<Integer, Fraction>());
			for(int j=1;j<5;j++){
				if(i<3)
					s.coeffmtrx.get(i).put(j,new Fraction(0));
			}
		}
		s.coeffmtrx.get(4).put(1,new Fraction (3));
		s.coeffmtrx.get(4).put(2,new Fraction (2));
		s.coeffmtrx.get(4).put(3,new Fraction (0));
		s.coeffmtrx.get(4).put(4,new Fraction (0));
		
		s.coeffmtrx.get(3).put(1,new Fraction (1));
		s.coeffmtrx.get(3).put(2,new Fraction (1));
		s.coeffmtrx.get(3).put(3,new Fraction (0));
		s.coeffmtrx.get(3).put(4,new Fraction (0));
		
		
		s.valVrbl.put(1, new Fraction (0));
		s.valVrbl.put(2, new Fraction (0));
		s.valVrbl.put(3, new Fraction (5));
		s.valVrbl.put(4, new Fraction (12));
		
		// Prob 3 :
		
		s.c.put(1, new Fraction(6));
		s.c.put(2, new Fraction(8));
		s.c.put(3, new Fraction(0));
		s.c.put(4, new Fraction(0));
		s.c.put(5, new Fraction(0));

		s.valObj=new Fraction (0);

		s.vrbl.put(1,0);
		s.vrbl.put(2,0);
		s.vrbl.put(3,1);
		s.vrbl.put(4,1);
		s.vrbl.put(5,1);
		
		for(int i=1;i<6;i++) {
			s.coeffmtrx.put(i,new HashMap<Integer, Fraction>());
			for(int j=1;j<6;j++){
				if(i<3)
					s.coeffmtrx.get(i).put(j,new Fraction(0));
			}
		}
		s.coeffmtrx.get(4).put(1,new Fraction (2));
		s.coeffmtrx.get(4).put(2,new Fraction (3));
		s.coeffmtrx.get(4).put(3,new Fraction (0));
		s.coeffmtrx.get(4).put(4,new Fraction (0));
		s.coeffmtrx.get(4).put(5,new Fraction (0));
		
		s.coeffmtrx.get(5).put(1,new Fraction (1));
		s.coeffmtrx.get(5).put(2,new Fraction (5));
		s.coeffmtrx.get(5).put(3,new Fraction (0));
		s.coeffmtrx.get(5).put(4,new Fraction (0));
		s.coeffmtrx.get(5).put(5,new Fraction (0));
		
		s.coeffmtrx.get(3).put(1,new Fraction (1));
		s.coeffmtrx.get(3).put(2,new Fraction (1));
		s.coeffmtrx.get(3).put(3,new Fraction (0));
		s.coeffmtrx.get(3).put(4,new Fraction (0));
		s.coeffmtrx.get(3).put(5,new Fraction (0));
		
		s.valVrbl.put(1, new Fraction (0));
		s.valVrbl.put(2, new Fraction (0));
		s.valVrbl.put(3, new Fraction (10));
		s.valVrbl.put(4, new Fraction (25));
		s.valVrbl.put(5, new Fraction (35));

/*
		pivot(s,6,1);
		pivot(s,5,3);
		pivot(s,3,2);
		
		for(int i=1;i<7;i++)
			System.out.println(i+ "|"+ s.vrbl.get(i));

		System.out.println();
*/
		
/*
		for(int i=1;i<7;i++)
			System.out.println(i+ "|"+ s.c.get(i));
		System.out.println();

		for(int i=1;i<7;i++){
			for(int j =1;j<7;j++){
				System.out.print(" "+ s.coeffmtrx.get(i).get(j)+"");


			}
			System.out.println();
		}*/
		/* Prob Mtrx 1
        int [][]A= new int [3][2];
        A[0][0]=1;
        A[0][1]=1;
        A[1][0]=2;
        A[1][1]=3;
        A[2][0]=1;
        A[2][1]=5;
        
        int []b= new int [3];
        b[0]=10;
        b[1]=25;
        b[2]=35;
        
        int c[]= new int [2];
        c[0]=6;
        c[1]=8;
        
        
        */ /* Prob Mtrx 2
		int [][]A= new int [2][2];
        A[0][0]=1;
        A[0][1]=1;
        A[1][0]=3;
        A[1][1]=2;
        
        int []b= new int [2];
        b[0]=5;
        b[1]=12;
               
        int c[]= new int [2];
        c[0]=6;
        c[1]=5;
		*/  //Prob Mtrx 3
	/*	int [][]A= new int [3][3];
        A[0][0]=1;
        A[0][1]=1;
        A[0][2]=3;
        A[1][0]=2;
        A[1][1]=2;
        A[1][2]=5;
        A[2][0]=4;
        A[2][1]=1;
        A[2][2]=2;
        
        int []b= new int [3];
        b[0]=30;
        b[1]=24;
        b[2]=36;
        
        int c[]= new int [3];
        c[0]=3;
        c[1]=1;
        c[2]=2;
		*/
	
		// Test for the initialisation problem
	/*		
		  int [][]A= new int [3][2];
	        A[0][0]=-1;
	        A[0][1]=-1;
	        A[1][0]=-1;
	        A[1][1]=1;
	        A[2][0]=1;
	        A[2][1]=0;
	        
	        int []b= new int [3];
	        b[0]=-2;
	        b[1]=-1;
	        b[2]=3;
	               
	        int c[]= new int [2];
	        c[0]=2;
	        c[1]=-1;
*/
/*		
		  int [][]A= new int [2][2];
	        A[0][0]=-1;
	        A[0][1]=1;
	        A[1][0]=1;
	        A[1][1]=-2;
	        
	        int []b= new int [2];
	        b[0]=-1;
	        b[1]=-2;
	               
	        int c[]= new int [2];
	        c[0]=-1;
	        c[1]=-2;
*/
	/*	
	  int [][]A= new int [2][2];
        A[0][0]=-2;
        A[0][1]=-3;
        A[1][0]=-5;
        A[1][1]=-2;
        
        int []b= new int [2];
        b[0]=-8;
        b[1]=-12;
               
        int c[]= new int [2];
        c[0]=-3;
        c[1]=-4;
*/       
/*
		int [][]A= new int [2][1];
        A[0][0]=1;
        A[1][0]=-1;
        
        int []b= new int [2];
        b[0]=10;
        b[1]=-10;
               
        int c[]= new int [1];
        c[0]=1;
*/
		/*
		int [][]A= new int [2][2];
        A[0][0]=1;
        A[0][1]=-1;
        A[1][0]=-1;
        A[1][1]=1;
        
        
        int []b= new int [2];
        b[0]=10;
        b[1]=-10;
               
        int c[]= new int [2];
        c[0]=1;
        c[1]=-1;
	*/
		
	//	/*
		int [][]A= new int [1][4];
        A[0][0]=-1;
        A[0][1]=-1;
        A[0][2]=1;
        A[0][3]=1;
        
        int []b= new int [1];
        b[0]=0;
        
               
        int c[]= new int [4];
        c[0]=-1;
        c[1]=-1;
        c[2]=1;
        c[3]=1;
//*/
	
		
	/*	System.out.println("in the main function");
		int n=Intialisation_Simplex( A , b, c).vrbl.size();
     for(int i=1;i<=n;i++)
			System.out.println(i+ "|"+ Intialisation_Simplex( A , b, c).vrbl.get(i));

		System.out.println();
		for(int i=1;i<=n;i++)
			System.out.println(i+ "|"+ Intialisation_Simplex( A , b, c).c.get(i));
		System.out.println();
		for(int i=1;i<=n;i++){
			for(int j =1;j<=n;j++){
				System.out.print(" "+Intialisation_Simplex( A , b, c).coeffmtrx.get(i).get(j)+"");


			}
			
		    System.out.println();
		    }
        */
//        Intialisation_Simplex( A , b, c);
		
	//	/*
		String nomDeFichier = "ex6.txt";	
		EnsembleVariable ens = new EnsembleVariable(nomDeFichier);

		System.out.print(ens.size() + " VARIABLES:");
		for (int i = 0; i < ens.size(); i++) System.out.print(ens.getVariable(i).getNom()+",");
		System.out.println();
		
//		Inequalite ine = new Inequalite("-10+1*i>=0",ens);ine.pulish(ens);System.out.println();
//		Invariant inv = new Invariant("{-10+1*i>=0,+10-1*i>=0,+0+0*i>=0}",ens);inv.publish(ens);
		
		Inequalite ine = new Inequalite("+0+1*i+0*j>=0",ens);ine.pulish(ens);System.out.println();
		Invariant inv = new Invariant("{+0+1*i+0*j>=0}",ens);inv.publish(ens);
	
		
		TransformToSimplex tts = new TransformToSimplex(inv, ine, 12);
		System.out.println("valeur optimal "+ tts.value());

		
		HashMap<Integer,Fraction> tmp = tts.solution();
		for(int i = 0;i<tmp.size();i++) System.out.println("vector optimal "+tmp.get(i));
		System.out.println("verifier Strict "+tts.verifierStrict());		
		System.out.print("The value of the objective function is "+LinearProgramming(Intialisation_Simplex( A , b, c)));
//*/
    //    System.out.print("The value of the objective function is "+LinearProgramming(Intialisation_Simplex( A , b, c)));
	}

}



